import { TableBase, TextTable } from '@/components/public-template';
import { QuestionBase, SelectQuestion, InputQuestion, TimeQuestion } from '@/components/public-template';

class virtualListService {
  //#region 查询表单
  getQuestions() {
    const questions: QuestionBase<any>[] = [
      new InputQuestion({ key: 'f1', label: '功能岛编号', type: 'text' }),
      new InputQuestion({ key: 'f2', label: '功能岛名称', type: 'text' }),
      new SelectQuestion({
        key: 'Type',
        label: '状态',
        placeholder: '请选择',
        value: '',
        options: [{ label: '全部', value: '' }],
        type: 'dictionary',
        state: {
          filterName: 'stateType'
        }
      })
    ];
    return questions.sort((a, b) => a.order - b.order);
  }
  //#endregion

  //#region 功能按钮组
  getIcons() {
    const icons: TableBase<any>[] = [
      new TextTable({
        key: 'add',
        value: '添加'
      }),
      new TextTable({
        key: 'add',
        value: '删除',
        class: 'ml10'
      }),
      new TextTable({
        key: 'add',
        value: '导入',
        class: 'ml10'
      }),
      new TextTable({
        key: 'add',
        value: '导出',
        class: 'ml10'
      })
    ];

    return icons.sort((a, b) => a.order - b.order);
  }
  //#endregion

  //#region 动态表格配置
  getTables() {
    const tables: TableBase<any>[] = [
      new TextTable({
        key: 'name',
        value: '功能岛编号'
      }),
      new TextTable({
        key: 'type',
        value: '功能岛名称'
      }),
      new TextTable({
        key: 'categoryIds',
        value: '所属实验室'
      }),
      new TextTable({
        key: 'categoryIds',
        value: '功能岛状态'
      }),
      new TextTable({
        key: 'categoryIds',
        value: '维保状态'
      }),
      new TextTable({
        key: 'actions',
        value: '操作',
        state: {
          width: 200
        },
        handle: [
          {
            type: 'delete',
            url: 'Course/Delete',
            text: '删除',
            class: 'text-primary',
            params: [{ id: 'id' }],
            state: {
              key: ''
            }
          }
        ]
      })
    ];

    return tables.sort((a, b) => a.order - b.order);
  }
  //#endregion
}

export default new virtualListService();
